package com.gskj.servicebase.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author :CodingFarmer_码农  Connor(康纳)_郭
 * @date : 14:24 20.5.13
 * @Company : http://www.gskj.com
 * @Version : 1.0
 * <p>
 * 自动填充 显示类
 */
@Component //加入 ioc
public class MyMetaObjectHandler implements MetaObjectHandler {

    // 插入填充
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("gmtCreate", new Date(), metaObject);
        this.setFieldValByName("gmtModified", new Date(), metaObject);

    }

    //修改填充
    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("gmtModified", new Date(), metaObject);
    }
}
